home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F251807_http_request.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-02-03  |  17.2 KB  |  416 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTP_REQUEST_H
  60. #define APACHE_HTTP_REQUEST_H
  61.  
  62. #include "apr_hooks.h"
  63. #include "util_filter.h"
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. #define AP_SUBREQ_NO_ARGS 0
  70. #define AP_SUBREQ_MERGE_ARGS 1
  71.  
  72. /**
  73.  * @file http_request.h
  74.  * @brief Apache Request library
  75.  */
  76.  
  77. /* http_request.c is the code which handles the main line of request
  78.  * processing, once a request has been read in (finding the right per-
  79.  * directory configuration, building it if necessary, and calling all
  80.  * the module dispatch functions in the right order).
  81.  *
  82.  * The pieces here which are public to the modules, allow them to learn
  83.  * how the server would handle some other file or URI, or perhaps even
  84.  * direct the server to serve that other file instead of the one the
  85.  * client requested directly.
  86.  *
  87.  * There are two ways to do that.  The first is the sub_request mechanism,
  88.  * which handles looking up files and URIs as adjuncts to some other
  89.  * request (e.g., directory entries for multiviews and directory listings);
  90.  * the lookup functions stop short of actually running the request, but
  91.  * (e.g., for includes), a module may call for the request to be run
  92.  * by calling run_sub_req.  The space allocated to create sub_reqs can be
  93.  * reclaimed by calling destroy_sub_req --- be sure to copy anything you care
  94.  * about which was allocated in its apr_pool_t elsewhere before doing this.
  95.  */
  96.  
  97. /**
  98.  * An internal handler used by the ap_process_request, all sub request mechanisms
  99.  * and the redirect mechanism.
  100.  * @param r The request, subrequest or internal redirect to pre-process
  101.  * @return The return code for the request
  102.  */
  103. AP_DECLARE(int) ap_process_request_internal(request_rec *r);
  104.  
  105. /**
  106.  * Create a sub request from the given URI.  This sub request can be
  107.  * inspected to find information about the requested URI
  108.  * @param new_file The URI to lookup
  109.  * @param r The current request
  110.  * @param next_filter The first filter the sub_request should use.  If this is
  111.  *                    NULL, it defaults to the first filter for the main request
  112.  * @return The new request record
  113.  * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_file, const request_rec *r)
  114.  */
  115. AP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_file,
  116.                                                 const request_rec *r,
  117.                                                 ap_filter_t *next_filter);
  118.  
  119. /**
  120.  * Create a sub request for the given file.  This sub request can be
  121.  * inspected to find information about the requested file
  122.  * @param new_file The URI to lookup
  123.  * @param r The current request
  124.  * @param next_filter The first filter the sub_request should use.  If this is
  125.  *                    NULL, it defaults to the first filter for the main request
  126.  * @return The new request record
  127.  * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r)
  128.  */
  129. AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file,
  130.                                               const request_rec *r,
  131.                                               ap_filter_t *next_filter);
  132. /**
  133.  * Create a sub request for the given apr_dir_read result.  This sub request 
  134.  * can be inspected to find information about the requested file
  135.  * @param finfo The apr_dir_read result to lookup
  136.  * @param r The current request
  137.  * @param subtype What type of subrequest to perform, one of;
  138.  * <PRE>
  139.  *      AP_SUBREQ_NO_ARGS     ignore r->args and r->path_info
  140.  *      AP_SUBREQ_MERGE_ARGS  merge r->args and r->path_info
  141.  * </PRE>
  142.  * @param next_filter The first filter the sub_request should use.  If this is
  143.  *                    NULL, it defaults to the first filter for the main request
  144.  * @return The new request record
  145.  * @deffunc request_rec * ap_sub_req_lookup_dirent(apr_finfo_t *finfo, int subtype, const request_rec *r)
  146.  * @tip The apr_dir_read flags value APR_FINFO_MIN|APR_FINFO_NAME flag is the 
  147.  * minimum recommended query if the results will be passed to apr_dir_read.
  148.  * The file info passed must include the name, and must have the same relative
  149.  * directory as the current request.
  150.  */
  151. AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *finfo,
  152.                                                    const request_rec *r,
  153.                                                    int subtype,
  154.                                                    ap_filter_t *next_filter);
  155. /**
  156.  * Create a sub request for the given URI using a specific method.  This
  157.  * sub request can be inspected to find information about the requested URI
  158.  * @param method The method to use in the new sub request
  159.  * @param new_file The URI to lookup
  160.  * @param r The current request
  161.  * @param next_filter The first filter the sub_request should use.  If this is
  162.  *                    NULL, it defaults to the first filter for the main request
  163.  * @return The new request record
  164.  * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_file, const request_rec *r)
  165.  */
  166. AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method,
  167.                                                 const char *new_file,
  168.                                                 const request_rec *r,
  169.                                                 ap_filter_t *next_filter);
  170. /**
  171.  * An output filter to strip EOS buckets from sub-requests.  This always
  172.  * has to be inserted at the end of a sub-requests filter stack.
  173.  * @param f The current filter
  174.  * @param bb The brigade to filter
  175.  * @deffunc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
  176.  */
  177. AP_CORE_DECLARE_NONSTD(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f,
  178.                                                         apr_bucket_brigade *bb);
  179.  
  180. /**
  181.  * Run the handler for the sub request
  182.  * @param r The sub request to run
  183.  * @return The return code for the sub request
  184.  * @deffunc int ap_run_sub_req(request_rec *r)
  185.  */
  186. AP_DECLARE(int) ap_run_sub_req(request_rec *r);
  187.  
  188. /**
  189.  * Free the memory associated with a sub request
  190.  * @param r The sub request to finish
  191.  * @deffunc void ap_destroy_sub_req(request_rec *r)
  192.  */
  193. AP_DECLARE(void) ap_destroy_sub_req(request_rec *r);
  194.  
  195. /*
  196.  * Then there's the case that you want some other request to be served
  197.  * as the top-level request INSTEAD of what the client requested directly.
  198.  * If so, call this from a handler, and then immediately return OK.
  199.  */
  200.  
  201. /**
  202.  * Redirect the current request to some other uri
  203.  * @param new_uri The URI to replace the current request with
  204.  * @param r The current request
  205.  * @deffunc void ap_internal_redirect(const char *new_uri, request_rec *r)
  206.  */
  207. AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r);
  208.  
  209. /**
  210.  * This function is designed for things like actions or CGI scripts, when
  211.  * using AddHandler, and you want to preserve the content type across
  212.  * an internal redirect.
  213.  * @param new_uri The URI to replace the current request with.
  214.  * @param r The current request
  215.  * @deffunc void ap_internal_redirect_handler(const char *new_uri, request_rec *r)
  216.  */
  217. AP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r);
  218.  
  219. /**
  220.  * Redirect the current request to a sub_req, merging the pools
  221.  * @param sub_req A subrequest created from this request
  222.  * @param r The current request
  223.  * @deffunc void ap_internal_fast_redirect(request_rec *sub_req, request_rec *r)
  224.  * @tip the sub_req's pool will be merged into r's pool, be very careful
  225.  * not to destroy this subrequest, it will be destroyed with the main request!
  226.  */
  227. AP_DECLARE(void) ap_internal_fast_redirect(request_rec *sub_req, request_rec *r);
  228.  
  229. /**
  230.  * Can be used within any handler to determine if any authentication
  231.  * is required for the current request
  232.  * @param r The current request
  233.  * @return 1 if authentication is required, 0 otherwise
  234.  * @deffunc int ap_some_auth_required(request_rec *r)
  235.  */
  236. AP_DECLARE(int) ap_some_auth_required(request_rec *r);
  237.  
  238. /**
  239.  * Determine if the current request is the main request or a sub requests
  240.  * @param r The current request
  241.  * @retrn 1 if this is a main request, 0 otherwise
  242.  * @deffunc int ap_is_initial_req(request_rec *r)
  243.  */
  244. AP_DECLARE(int) ap_is_initial_req(request_rec *r);
  245.  
  246. /**
  247.  * Function to set the r->mtime field to the specified value if it's later
  248.  * than what's already there.
  249.  * @param r The current request
  250.  * @param dependency_time Time to set the mtime to
  251.  * @deffunc void ap_update_mtime(request_rec *r, apr_time_t dependency_mtime)
  252.  */
  253. AP_DECLARE(void) ap_update_mtime(request_rec *r, apr_time_t dependency_mtime);
  254.  
  255. /**
  256.  * Add one or more methods to the list permitted to access the resource.
  257.  * Usually executed by the content handler before the response header is
  258.  * sent, but sometimes invoked at an earlier phase if a module knows it
  259.  * can set the list authoritatively.  Note that the methods are ADDED
  260.  * to any already permitted unless the reset flag is non-zero.  The
  261.  * list is used to generate the Allow response header field when it
  262.  * is needed.
  263.  * @param   r     The pointer to the request identifying the resource.
  264.  * @param   reset Boolean flag indicating whether this list should
  265.  *                completely replace any current settings.
  266.  * @param   ...   A NULL-terminated list of strings, each identifying a
  267.  *                method name to add.
  268.  * @return  None.
  269.  * @deffunc void ap_allow_methods(request_rec *r, int reset, ...)
  270.  */
  271. AP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...);
  272.  
  273. /**
  274.  * Add one or more methods to the list permitted to access the resource.
  275.  * Usually executed by the content handler before the response header is
  276.  * sent, but sometimes invoked at an earlier phase if a module knows it
  277.  * can set the list authoritatively.  Note that the methods are ADDED
  278.  * to any already permitted unless the reset flag is non-zero.  The
  279.  * list is used to generate the Allow response header field when it
  280.  * is needed.
  281.  * @param   r     The pointer to the request identifying the resource.
  282.  * @param   reset Boolean flag indicating whether this list should
  283.  *                completely replace any current settings.
  284.  * @param   ...   A list of method identifiers, from the "M_" series
  285.  *                defined in httpd.h, terminated with a value of -1
  286.  *                (e.g., "M_GET, M_POST, M_OPTIONS, -1")
  287.  * @return  None.
  288.  * @deffunc void ap_allow_standard_methods(request_rec *r, int reset, ...)
  289.  */
  290. AP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...);
  291.  
  292. #define MERGE_ALLOW 0
  293. #define REPLACE_ALLOW 1
  294.  
  295. #ifdef CORE_PRIVATE
  296. /* Function called by main.c to handle first-level request */
  297. void ap_process_request(request_rec *);
  298. /**
  299.  * Kill the current request
  300.  * @param type Why the request is dieing
  301.  * @param r The current request
  302.  * @deffunc void ap_die(int type, request_rec *r)
  303.  */
  304. AP_DECLARE(void) ap_die(int type, request_rec *r);
  305. #endif
  306.  
  307. /* Hooks */
  308.  
  309. /**
  310.  * Gives modules a chance to create their request_config entry when the
  311.  * request is created.
  312.  * @param r The current request
  313.  * @ingroup hooks
  314.  */
  315. AP_DECLARE_HOOK(int,create_request,(request_rec *r))
  316.  
  317. /**
  318.  * This hook allow modules an opportunity to translate the URI into an
  319.  * actual filename.  If no modules do anything special, the server's default
  320.  * rules will be followed.
  321.  * @param r The current request
  322.  * @return OK, DECLINED, or HTTP_...
  323.  * @ingroup hooks
  324.  */
  325. AP_DECLARE_HOOK(int,translate_name,(request_rec *r))
  326.  
  327. /**
  328.  * This hook allow modules to set the per_dir_config based on their own
  329.  * context (such as <Proxy > sections) and responds to contextless requests 
  330.  * such as TRACE that need no security or filesystem mapping.
  331.  * based on the filesystem.
  332.  * @param r The current request
  333.  * @return DONE (or HTTP_) if this contextless request was just fulfilled 
  334.  * (such as TRACE), OK if this is not a file, and DECLINED if this is a file.
  335.  * The core map_to_storage (HOOK_RUN_LAST) will directory_walk and file_walk
  336.  * the r->filename.
  337.  * 
  338.  * @ingroup hooks
  339.  */
  340. AP_DECLARE_HOOK(int,map_to_storage,(request_rec *r))
  341.  
  342. /**
  343.  * This hook is used to analyze the request headers, authenticate the user,
  344.  * and set the user information in the request record (r->user and
  345.  * r->ap_auth_type). This hook is only run when Apache determines that
  346.  * authentication/authorization is required for this resource (as determined
  347.  * by the 'Require' directive). It runs after the access_checker hook, and
  348.  * before the auth_checker hook.
  349.  *
  350.  * @param r The current request
  351.  * @return OK, DECLINED, or HTTP_...
  352.  * @ingroup hooks
  353.  */
  354. AP_DECLARE_HOOK(int,check_user_id,(request_rec *r))
  355.  
  356. /**
  357.  * Allows modules to perform module-specific fixing of header fields.  This
  358.  * is invoked just before any content-handler
  359.  * @param r The current request
  360.  * @return OK, DECLINED, or HTTP_...
  361.  * @ingroup hooks
  362.  */
  363. AP_DECLARE_HOOK(int,fixups,(request_rec *r))
  364.  
  365. /**
  366.  * This routine is called to determine and/or set the various document type
  367.  * information bits, like Content-type (via r->content_type), language, et
  368.  * cetera.
  369.  * @param r the current request
  370.  * @return OK, DECLINED, or HTTP_...
  371.  * @ingroup hooks
  372.  */
  373. AP_DECLARE_HOOK(int,type_checker,(request_rec *r))
  374.  
  375. /**
  376.  * This hook is used to apply additional access control to this resource.
  377.  * It runs *before* a user is authenticated, so this hook is really to
  378.  * apply additional restrictions independent of a user. It also runs
  379.  * independent of 'Require' directive usage.
  380.  *
  381.  * @param r the current request
  382.  * @return OK, DECLINED, or HTTP_...
  383.  * @ingroup hooks
  384.  */
  385. AP_DECLARE_HOOK(int,access_checker,(request_rec *r))
  386.  
  387. /**
  388.  * This hook is used to check to see if the resource being requested
  389.  * is available for the authenticated user (r->user and r->ap_auth_type).
  390.  * It runs after the access_checker and check_user_id hooks. Note that
  391.  * it will *only* be called if Apache determines that access control has
  392.  * been applied to this resource (through a 'Require' directive).
  393.  *
  394.  * @param r the current request
  395.  * @return OK, DECLINED, or HTTP_...
  396.  * @ingroup hooks
  397.  */
  398. AP_DECLARE_HOOK(int,auth_checker,(request_rec *r))
  399.  
  400. /**
  401.  * This hook allows modules to insert filters for the current request
  402.  * @param r the current request
  403.  * @ingroup hooks
  404.  */
  405. AP_DECLARE_HOOK(void,insert_filter,(request_rec *r))
  406.  
  407. AP_DECLARE(int) ap_location_walk(request_rec *r);
  408. AP_DECLARE(int) ap_directory_walk(request_rec *r);
  409. AP_DECLARE(int) ap_file_walk(request_rec *r);
  410.  
  411. #ifdef __cplusplus
  412. }
  413. #endif
  414.  
  415. #endif    /* !APACHE_HTTP_REQUEST_H */
  416.